package com.lechuang.order.manager.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.lechuang.common.request.PageRequest;
import com.lechuang.common.result.PageResult;
import com.lechuang.order.entity.Test;
import com.lechuang.order.manager.TestManager;
import com.lechuang.order.service.TestService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TestManagerImpl implements TestManager {
    @Resource
    private TestService testService;

    @Override
    public void insert(String name) {
        Test test = new Test().setName(name);
        testService.save(test);
    }

    @Override
    public List<Test> list() {
        return testService.list();
    }

    @Override
    public PageResult<Test> page(PageRequest<String> pageRequest) {
        Page<Test> page = new Page<>(pageRequest.getPageNum(), pageRequest.getPageSize());
        Page<Test> pageData = testService.page(page);
        return PageResult.result(pageData.getRecords(), page, pageRequest, null);
    }
}
